<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<jsp:useBean id="today" class="java.util.Date" />

<c:import url="/view/admin/include/header/adminHeader.jsp"></c:import>
    <!-- 컨텐츠 부분 -->
	<div id="container">
    	<!-- 왼쪽 메뉴 부분 -->
    	<c:import url="/view/admin/include/left/adminLeft.jsp"></c:import>
        <!-- 왼쪽 메뉴 부분 -->
        <!-- 오른쪽 내용 부분 -->
        <input type="hidden" name="board_code" id="board_code" value="${boardView.board_code }"/>
        <dl>
        	<dd class="path">
        	홈 > 게시판 관리 > 
        		<span class="path_b">
        			<s:if test="%{boardBean.board_code.equals('BD100')}" >공지사항</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD201')}" >윤리경영 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD202')}" >준법지원 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD203')}" >공정거래 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD204')}" >업무지원 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD205')}" >법률자문요청</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD206')}" >소송개시요청</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD501')}" >영업 사례해설 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD502')}" >설치 사례해설 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD503')}" >서비스 사례해설 Q&A</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD301')}" >윤리경영 자료실</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD302')}" >준법지원 자료실</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD303')}" >공정거래 자료실</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD304')}" >업무지원 자료실</s:if>
        			<s:if test="%{boardBean.board_code.equals('BD400')}" >사이버제보 </s:if>
        		</span>
        	</dd>
        </dl>
        <dl class="content">
            <dd class="">
            	<table cellspacing="0" cellpadding="0" summary="" >
                	<caption></caption>
                    	 <colgroup>
                          <col width="15%;"/>
                          <col width="45%;"/>
                          <col width="10%;"/>
                          <col width="30%"/>
                         </colgroup>
                    <tbody>
                    	<tr>
                        	<th scope="rows" class="table_txt_left">질문자</th>
                            <td class="table_txt_left">${boardView.mem_name }</td>
                            <th scope="rows" class="table_txt_left">질문일</th>
                            <td class="table_txt_left">${boardView.write_time}</td>
                        </tr>
                    	<tr>
                        	<th scope="rows" class="table_txt_left">질문 제목</th>
                            <td colspan="3" class="table_txt_left f_blue " colspan="2">${boardView.title}</td>
                        </tr>
                        <tr>
                        	<th scope="rows" class="padding30 table_txt_left">질문 내용</th>
                            <td class="table_txt_left padding30" colspan="3">${boardView.content }</td>
                        </tr> 
                        <tr>
                        	<th scope="rows" class="table_td_bottom table_txt_left">첨부파일</th>
                            <td class="table_txt_left table_td_bottom" colspan="3">
                            	<s:if test="%{fileView.file_name1 != null}">
                            		<a href="/board/fileDownload.hcom?board_seq=${boardView.board_seq }&save_type=board&attach_seq=${fileView.attach_seq1}">${fileView.file_name1 }</a>
                            	</s:if>
                            	<s:if test="%{fileView.file_name2 != null}">
                            		<a href="/board/fileDownload.hcom?board_seq=${boardView.board_seq }&save_type=board&attach_seq=${fileView.attach_seq2}">${fileView.file_name2 }</a>
                            	</s:if>
                            	<s:if test="%{fileView.file_name3 != null}">
                            		<a href="/board/fileDownload.hcom?board_seq=${boardView.board_seq }&save_type=board&attach_seq=${fileView.attach_seq3}">${fileView.file_name3 }</a>
                            	</s:if>   
                            	<s:else>파일없음</s:else>
                            </td>
                        </tr>                
                    </tbody>
                 </table>
                   <dd class="btn_right">
            	<input type="button" id="powerdelete" value="삭제" class="input_btn_s b" />
            	</dd>
            </dd>
			<c:if test="${boardView.answer_flag == 'Y' }">            
            <dd class="list">
            	<div>
	            	<table cellspacing="0" cellpadding="0" summary="" >
	                	<caption></caption>
	                    	 <colgroup>
	                          <col width="15%;"/>
	                          <col width="35%;"/>
	                          <col width="15%;"/>
	                          <col width="35%;"/>
	                         </colgroup>	                         
	                    <tbody id="limitReplys">
	                    	<!-- 댓글 리스트-->
	                    		<tr>
                        			<td scope="rows" class="table_txt_left f_black b">답변작성일</td>
                            		<td class="table_txt_left">${boardView.answer_write_time }</td>
                            		<td scope="rows" class="table_txt_left f_black b">답변자</td>
                            		<td class="table_txt_left">${boardView.answer_mem_name }</td>
                        		</tr>                 
			                    <tr>
			                    	<td scope="rows" class="table_txt_left f_black b table_td_bottom_dotted">답변 내용 </td>
			                        <td class="table_txt_left table_td_bottom_dotted" colspan="3">${boardView.answer_content}</td>
			                    </tr>  
			                    <tr>
			                    	<td scope="rows" class="table_txt_left f_black b table_td_bottom_dotted">첨부 파일 </td>
			                        <td class="table_txt_left table_td_bottom_dotted" colspan="3">
			                        	<a href="/board/fileoneDownload.hcom?board_seq=${boardView.board_seq }&save_type=answer">${answerFile.file_name}</a>
			                        </td>
			                    </tr>  
	                        <!-- 댓글 끝-->                      
	                    </tbody>	                    	                    
	                 </table>
                 </div>
            </dd>
            <dd class="btn_right">
            	<input type="button" id="btnUpdate" value="수정" class="input_btn_s b" />
            	<input type="button" id="btnDel" value="삭제" class="input_btn_s b" />
            	<input type="button" id="btnList" value="목록" class="input_btn_s b" />
            </dd>
            </c:if>
            <c:if test="${boardView.answer_flag == 'N' }">
            <dd class="list">
            	<form id="replyFrm" name="replyFrm" method="post" action="/admin/insertAnswer.hcom" enctype="multipart/form-data">
            		<input type="hidden" id="answer_mem_no" name="answer_mem_no" value="<s:property value="#session.id" />" />
            		<input type="hidden" id="answer_mem_name" name="answer_mem_name" value="<s:property value="#session.name" />" />
            		<input type="hidden" id="board_seq" name="board_seq" value="${boardView.board_seq }" />
            		<input type="hidden" id="board_code" name="board_code" value="${boardView.board_code }" />
            		<input type="hidden" id="save_type" name="save_type" value="answer" />
            	<div>
	            	<table cellspacing="0" cellpadding="0" summary="" >
	                	<caption></caption>
	                    	 <colgroup>
	                          <col width="10%;"/>
	                          <col width="20%;"/>
	                          <col width="70%;"/>
	                         </colgroup>
	                    <tbody>
	                    	<tr>
	                        	<td class="table_txt_left padding5">
	                        		<span class="f_black b">답변 내용 </span>
	                        	</td>
	                            <td class="table_td_bottom_x padding5"></td>
	                            <td class="table_td_bottom_x padding5"></td>
	                        </tr>
	                        <tr>
	                        	<td class="table_txt_left" colspan="3"><textarea id="answer_content" name="answer_content" style="width:99%; height:150px;" ></textarea></td>
	                        </tr>  
	                        <tr>
	                        	<td class="table_txt_left padding5 table_td_bottom_comment ">
	                        		<span class="f_black b">첨부파일</span>
	   							</td>
	   							<td colspan="2" class="table_txt_left table_td_bottom_comment" >
	   								<input type="text" id="file_name" class="input" style="width:200px; height:14px;"  title="첨부파일" readonly="readonly"/>
                  					<span class="file_input">
                  						<input type="file" name="upload" class="file_input_hidden" title="첨부파일" onchange="javascript: document.getElementById('file_name').value = this.value" style="cursor: pointer;"/>
                  						<img src="/images/common/btn_file.gif" alt="첨부파일" name="find" id="find" border="0" style="cursor: pointer;"/>10MB이내 첨부
                  					</span>
	   							</td>
	                        </tr>                      
	                    </tbody>                    	                    
	                 </table>
                 </div>
                 </form>
            </dd>
            <dd class="btn_right">
            	<input type="button" id="btnReplyWrite" value="쓰기" class="input_btn_s b" />
            	<input type="button" id="btnList" value="목록" class="input_btn_s b" />
            </dd>
            </c:if>
        </dl>
        <!-- 오른쪽 내용 부분 -->
    </div>
    <!-- 컨텐츠 부분 -->
<c:import url="/view/admin/include/footer/adminFooter.jsp"></c:import>
<script type="text/javascript" src="/js/portal/board.js"></script>
<script type="text/javascript">
	$().ready(function(){
		$("#btnList").click(function(){
			location.href="/admin/qnaList.hcom?board_code=${boardView.board_code }";
		});
		$("#btnDel").click(function(){
			if(confirm("답변을 삭제하시겠습니까?")){
				location.href="/admin/deleteAnswer.hcom?board_seq=${boardView.board_seq}&attach_seq=${answerFile.attach_seq}";	
			}
		});
		$("#btnUpdate").click(function(){
			location.href="/admin/updateAnswerForm.hcom?board_seq=${boardView.board_seq }&save_type=answer";	
		});	
		$("#powerdelete").click(function(){
			if(confirm("삭제하시겠습니까?")){
			location.href="/admin/powerdeleteBoard.hcom?board_seq=${boardView.board_seq }&board_code=${boardView.board_code}";
			}
		});
		$("#btnReplyWrite").click(function(){
			oEditors[0].exec("UPDATE_CONTENTS_FIELD", []);
			
			if($("#answer_content").val() != ''){
				$("#replyFrm").submit();
			}else{
				alert("댓글의 내용이 없습니다.");
				$("#answer_content").focus();
				return false;
			}
		});			
	});
	
	var oEditors = [];
	// 에디터 생성
	nhn.husky.EZCreator.createInIFrame({
		oAppRef: oEditors,
		elPlaceHolder: "answer_content",
		sSkinURI: "/sEditor/SmartEditor2Skin.html",
		fCreator: "createSEditor2",		
	});	
	
	function pasteHTMLDemo(){
		sHTML = "<span style='color:#FF0000'>이미지 등도 이렇게 삽입하면 됩니다.</span>";
		oEditors.getById["answer_content"].exec("PASTE_HTML", [sHTML]);
	}

	function showHTML(){
		alert(oEditors.getById["answer_content"].getIR());
	}
	
</script>